﻿
CREATE PROCEDURE [dbo].[proc_Project_GetList_OrderId]
(
	@OrderId uniqueidentifier
)
AS
Begin
	Select
	P.Id,
	P.ProjectId,
	P.OrderId,
	P.ProductId,
	P.CostPrice,
	P.SalePrice,
	P.Description,
	P.TypeId,
	P.IsFinish,
	P.SupplierId,
	P.CompanyId,
	p.CreateUser,
	p.Salesman,
	p.SalesmanAccount,
	p.ProductName,
	p.TypeName,
	p.SupplierName,
	IsNull((Select EName From Employee Where UserName=p.CreateUser),p.CreateUser) As CreateUserEName,
	IsNull(p.CreateDate,p.UpTime) as CreateDate,
	IsNull(p.FinishDate,'1910/01/01') as FinishDate,
	ExecPerson,
	IsNull((Select top 1 Employee.MobilePhone From Employee Where Employee.UserName=p.ExecPerson),'...') As ExecPersonTel,
	FinanceAudit,MoveCompanyId,IsHedge,
	IsNull((select product.flag from product where product.id=p.productid),0) flag
	From Project p Where OrderId=@OrderId 
	Order By p.SupplierId,p.ProductId,p.id
End